<?php
/* @var $this CountAdminController */
/* @var $model CountAdmin */

$this->breadcrumbs = array(
    'Count Admins' => array('index'),
    'Create',
);
Yii::app()->clientScript->registerCoreScript('jquery');

$this->menu = array(
    array('label'=>'统计', 'url'=>array('company')),
    array('label'=>'最近20天', 'url'=>array('companyCountDay')),
    array('label'=>'最近12个月', 'url'=>array('companyCountYear')),
);
?>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/highcharts.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/gray.js"></script>
<div class="countnum">总用户数:<?php echo $count_users;?> 总访问数:<?php echo $count_connections;?></div>
<!-- <div style="float: right;">
    <?php
    echo CHtml::dropDownList('gatewayname', $selected,CHtml::listData(Gateway::model()->findAll(' companyid='.Yii::app()->User->id), 'id', 'gatewayname'),
        array('empty'=>'-- All --','onchange'=>'onCilentChange(this)'));
    ?>
</div> -->
<div id="contents" style="width: 100%; height: 100%; margin: 0 auto"></div>
<script type="text/javascript">
    function onCilentChange(obj){
        var gwid = obj.value;
        location.href='<?php echo Yii::app()->createUrl('countAdmin/CompanyCountYear')?>&gatewayid='+gwid;
    }
    $(function () {
        var colorx = Highcharts.getOptions().colors;
        $('#contents').highcharts({
            chart: {
                type: 'column'
            },
            title: {
                text: '统计最近12个月'
            },
            xAxis: {
                categories: [<?php foreach ($x as $v) { echo "'".$v."',";} ?>]

            },
            yAxis: {
                title: {
                    text: '12个月/月',
                    align: 'high'
                },
                min: 0,
                alternateGridColor: null
            },
            tooltip: {
                valueSuffix: ''
            },
            plotOptions: {
                spline: {
                    lineWidth: 4,
                    states: {
                        hover: {
                            lineWidth: 5
                        }
                    },
                    marker: {
                        enabled: false
                    }
                }
            },
            series: [
                {
                    name: '当月用户数',
                    data: [<?php  foreach ($y as $k=>$v) {
                    echo "{color: '#DDDF0D', y:".$v['user_to_day']."},";
                } ?>], dataLabels: {
                    color: '#DDDF0D',
                    align: 'center',
                    style: {
                        fontSize: '13px',
                        fontFamily: 'Verdana, sans-serif',
                        textShadow: '0 0 1px #DDDF0D'
                    }
                }
                },
                {
                    name: '当月登陆数',
                    data: [<?php  foreach ($y as $k=>$v) {
                    echo "{color: '#7798BF', y:".$v['connection_to_day']."},";
                } ?>], dataLabels: {
                    color: '#7798BF',
                    align: 'center',
                    style: {
                        fontSize: '13px',
                        fontFamily: 'Verdana, sans-serif',
                        textShadow: '0 0 1px #7798BF'
                    }
                }
                },
                {
                    name: '当月路人数',
                    data: [<?php  foreach ($y as $k=>$v) {
                    echo "{color: '#8c8c8c', y:".$v['guests']."},";
                } ?>], dataLabels: {
                    align: 'center',
                    style: {
                        fontSize: '13px',
                        fontFamily: 'Verdana, sans-serif',
                        textShadow: '0 0 1px #8c8c8c'
                    }
                }
                }
            ],credits: {
                enabled: false
            }
        });
    });
</script>

